﻿using System;
using System.Runtime.Serialization;
using MugenMvvmToolkit.Interfaces;
using MugenMvvmToolkit.Utils;

namespace MugenMvvmToolkit.Models
{
    /// <summary>
    ///  Represents the interface which contains information about binding a view to a view model as page.
    /// </summary>
#if WPF
    [Serializable]
#endif
    [DataContract]
    public class ViewPageMappingItem : IViewPageMappingItem
    {
        #region Constructor

        /// <summary>
        ///     Initializes a new instance of the <see cref="ViewPageMappingItem" /> class.
        /// </summary>
        public ViewPageMappingItem(Uri uri, Type viewModelType, Type viewType, string name)
        {
            Should.NotBeNull(uri, "uri");
            Should.NotBeNull(viewModelType, "viewModelType");
            Should.NotBeNull(viewType, "viewType");
            Should.BeViewModel(viewModelType, "viewModelType");
            Should.BeView(viewType, "viewType");
            Uri = uri;
            ViewModelType = viewModelType;
            ViewType = viewType;
            Name = name;
        }

        #endregion

        #region Implementation of IViewPageMappingItem

        /// <summary>
        ///     Gets the name of mapping.
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        ///     Gets the type of view.
        /// </summary>
        public Type ViewType { get; private set; }

        /// <summary>
        ///     Gets or sets the type of view model.
        /// </summary>
        public Type ViewModelType { get; private set; }

        /// <summary>
        ///     Gets the <see cref="IViewPageMappingItem.Uri" />.
        /// </summary>
        public Uri Uri { get; private set; }

        #endregion
    }
}